from util.pay import AliPay
from ronglian_sms_sdk import SmsSDK

accId = '8aaf070882ede8b30183546f02d4123b'
accToken = '5cf32cb45a1944c18bf1fc54a6553c0a'
appId = '8aaf070882ede8b30183546f03ae1242'

def send_message(mobile):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    datas = (code,"1分钟")
    resp = sdk.sendMessage(tid, mobile, datas)
    print(resp)
    return resp


# 导入支付基类

# 初始化阿里支付对象
def get_ali_object():
    # 沙箱环境地址：https://openhome.alipay.com/platform/appDaily.htm?tab=info
    app_id = "2021000121654771"  # APPID （沙箱应用）

    # 支付完成后，支付偷偷向这里地址发送一个post请求，识别公网IP,如果是 192.168.20.13局域网IP ,支付宝找不到，def page2() 接收不到这个请求
    notify_url = "http://localhost:8000/user/callback/"

    # 支付完成后，跳转的地址。
    return_url = "http://localhost:8000/user/callback/"

    merchant_private_key_path = "keys/private_key.txt"  # 应用私钥
    alipay_public_key_path = "keys/public_key.txt"  # 支付宝公钥

    alipay = AliPay(
        appid=app_id,
        app_notify_url=notify_url,
        return_url=return_url,
        app_private_key_path=merchant_private_key_path,
        alipay_public_key_path=alipay_public_key_path,  # 支付宝的公钥，验证支付宝回传消息使用，不是你自己的公钥
        debug=True,  # 默认False,
    )
    return alipay
